--- googleanalytics.admin.inc	Wed Nov 26 14:36:50 2008
+++ googleanalytics.admin.inc	Fri Feb 20 13:50:14 2009
@@ -129,6 +129,13 @@
     '#size' => (count($fields)>10) ? 10 : count($fields),
     '#multiple' => TRUE
   );
+  
+  if (module_exists('og')) {
+    $form['segmentation']['googleanalytics_og_segmentation'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Segment users by Organic Groups'),
+      '#description' => t('All groups will be tracked'),
+      '#default_value' => variable_get('googleanalytics_og_segmentation', FALSE),
+    );
+  }
 
   // Link specific configurations.
   $form['linktracking'] = array(
--- googleanalytics.admin.inc	Mon Oct 13 16:48:49 2008
+++ googleanalytics.admin.inc	Fri Feb 20 13:54:10 2009
@@ -91,7 +91,7 @@
   if (!empty($id) && _googleanalytics_visibility_pages() && _googleanalytics_visibility_user($user)) {
 
     // Add User profile segmentation values.
-    if (is_array($profile_fields = variable_get('googleanalytics_segmentation', '')) && ($user->uid > 0)) {
+    if ((is_array($profile_fields = variable_get('googleanalytics_segmentation', '')) || variable_get('googleanalytics_og_segmentation', FALSE)) && ($user->uid > 0)) {
 
       $p = module_invoke('profile', 'load_profile', $user);
 
@@ -104,6 +104,14 @@
         }
 
         $fields[$field] = $value;
+      }
+      
+      if (variable_get('googleanalytics_og_segmentation', FALSE) && isset($user->og_groups)) {
+        $groups = array();
+        foreach($user->og_groups as $nid => $group) {
+          $groups[] = $nid . '-' . check_plain($group['title']);
+        }
+        $fields += $groups;
       }
 
       // Only show segmentation variable if there are specified fields.
